<html>
    <head>
        <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
        <script type="text/javascript" src="scripts/htmlutils.js"></script> 
        <script type="text/javascript">
        
        function getQueryParam (searchKey) {
        var topWindow = window.parent;
        var str = topWindow.location.search.substr(1);
        if (str == null) return null;

        var clauses = str.split('&');

        for (var i = 0; i < clauses.length; i++) {
            var keyValuePair = clauses[i].split('=', 2);
            var key = unescape(keyValuePair[0]);
            if (key == "GI" || key == "APP" )
             topWindow.storedVars[key] = prepareUrl( unescape(keyValuePair[1]) );
            else 
            topWindow.storedVars[key] = unescape(keyValuePair[1]); // save query params in 
            if (key == searchKey) {
                return unescape(keyValuePair[1]);
            }
        }
        return null;
        }
        
        prepareUrl = function(includeUrl) {
          // using selenium-core handling of urls (see absolutify in htmlutils.js)
          var topWindow = window.parent;
          var baseUrl = topWindow.location.href.split('?')[0];
          var prepareUrl;
          // htmlSuite mode of SRC? TODO is there a better way to decide whether in SRC mode?
          if (topWindow.location.href.indexOf("selenium-server") != -1) {
              preparedUrl = absolutify(includeUrl, topWindow.htmlTestRunner.controlPanel.getTestSuiteName());
          } else {
              preparedUrl = absolutify(includeUrl, baseUrl);
          }
          return preparedUrl;
        };
        
        function load_tests() {
          var table = document.getElementById("suiteTable");
          var tests = getQueryParam("TESTS");
          var topWindow = window.parent;
          var appPath = topWindow.storedVars["APP"]; //getQueryParam("APP");         
          if (tests) {
            var testcases = tests.slice(1,-1).split(",");
            if (table) {           
              for (var i = 0; i < testcases.length; i++) {
                var newRow = table.insertRow(1);
                var newCell = newRow.insertCell(0)
                var name = testcases[i];
                var testcase = ["<a href='", appPath+name, "'>",name, "</a>\n"].join("");
                newCell.innerHTML = testcase;
              }
            }
          }
        }
        </script>
    </head>
<body onload="load_tests();" >
<table id="suiteTable" class="selenium ">
<tbody>
<tr><td>GI Builder Test Case Runner</td></tr>
<tbody>
</table>
</body>
</html>
